﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" validateRequest="false"  CodeBehind="AdminWrite.aspx.cs" Inherits="NuaTarDoneng.UeditorTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" charset="utf-8" src="../ueditor/editor_config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../ueditor/editor_all.js"></script>
   
    <style type="text/css">

     
        #footer
        {
         display:none;   
         }
        .style216
        {
            width: 100%;
            line-height:24px;
        }
        .style217
        {
            text-align: right;
        }
        .style218
        {}
        .style219
        {
            text-align: left;
        }
    </style>
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div style="height:auto;">
        <table class="style216">
            <tr>
                <td colspan="2" class="style218">
                    <asp:Label ID="alarms" runat="server" ClientIDMode="Static" 
                        style="color: #FF0000" Text="出现异常错误" Visible="False"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="style218">
                    标题：<asp:TextBox ID="titletb" runat="server" Width="329px"></asp:TextBox>
&nbsp;<asp:HiddenField ID="BlogID" runat="server" />
                </td>
            </tr>
            <tr>
                <td class="style219">
                    关键字：<asp:TextBox ID="keytb" runat="server" Width="316px"></asp:TextBox>
                    类别：<asp:DropDownList ID="sortlist" runat="server" 
                        DataSourceID="SqlDataSource1" DataTextField="blogSort" 
                        DataValueField="blogSortID" Width="111px">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        SelectCommand="SELECT [blogSort], [blogSortID] FROM [blogSort]">
                    </asp:SqlDataSource>
                </td>
                <td class="style217">
                   
                    <asp:Button ID="BTsubmit" runat="server" onclick="Button1_Click" Text="提交" ClientIDMode="Static" />
                </td>
            </tr>
        </table>
        <div style="width:auto;margin:0px auto 0px auto;">
            <asp:TextBox ID="myEditor" runat="server" ClientIDMode="Static" TextMode="MultiLine">&lt;p&gt;新文章内容&lt;/p&gt;</asp:TextBox> 
        </div>

  
<script type="text/javascript">
    //实例化编辑器
    var ue = UE.getEditor('myEditor');

    ue.addListener('ready', function () {
        this.focus()
    });

    function createEditor() {
        enableBtn();
        UE.getEditor('myEditor')
    }
    function getAllHtml() {
        alert(UE.getEditor('myEditor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('myEditor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('myEditor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
        UE.getEditor('myEditor').setContent('欢迎使用ueditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UE.getEditor('myEditor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('myEditor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UE.getEditor('myEditor').selection.getRange();
        range.select();
        var txt = UE.getEditor('myEditor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UE.getEditor('myEditor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UE.getEditor('myEditor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UE.getEditor('myEditor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('myEditor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
</script>


</div>
</asp:Content>
